<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
$member_id=$_POST[member_id]?$_POST[member_id]:0;
$is_ok=$_POST[is_ok]?$_POST[is_ok]:0;
@mysql_query("insert into adwords (member_id,type_id,ad_id,ad_url,ad_picture,ad_addtime,ad_endtime,ad_shuoming,is_ok) values ('$member_id','$_POST[type_id]','$_POST[ad_id]','$_POST[ad_url]','$_POST[picture]','$_POST[ad_addtime]','$_POST[ad_endtime]','$_POST[ad_shuoming]',$is_ok)");
echo "<script>alert('添加成功');location='".$_POST['urls']."';</script>";
}
?>
<?php
if($_POST['act_xg']){
$member_id=$_POST[member_id]?$_POST[member_id]:0;
$is_ok=$_POST[is_ok]?$_POST[is_ok]:0;
@mysql_query("update adwords set member_id='$member_id',type_id='$_POST[type_id]',ad_id='$_POST[ad_id]',ad_url='$_POST[ad_url]',ad_picture='$_POST[picture]',ad_addtime='$_POST[ad_addtime]',ad_endtime='$_POST[ad_endtime]',ad_shuoming='$_POST[ad_shuoming]',is_ok='$is_ok' where id='".$_POST['iid']."'");
echo "<script>alert('修改成功');location='".$_POST['urls']."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/shijian.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">广告管理系统&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="" onSubmit="return check()" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加热点产品目录</td>
    </tr>
    <tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">会员编号[ID]</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="member_id" type="text" id="member_id" size="30" maxlength="100"></td>
    </tr>
    <tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">广告类型</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="type_id" id="type_id">
	     <option value="">选择广告类型</option>
	     <option value="1">热点产品广告</option>
		 <option value="2">产品栏目列表广告</option>
	  </select></td>
    </tr>
	<tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">页面编号[ID]</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_id" type="text" id="ad_id" size="20"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">链接地址</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_url" type="text" id="ad_url" size="40"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">图片地址</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="picture" type="text" id="picture" size="30">&nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">开始时间</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_addtime" type="text" id="ad_addtime" size="20" onClick="setDay(this);"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">结束时间</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_endtime" type="text" id="ad_endtime" size="20" onClick="setDay(this);"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">备注</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><textarea name="ad_shuoming" cols="60" rows="10" id="ad_shuoming"></textarea></td>
	 </tr>
	 <tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">是否显示</td>
	   <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	   <input name="is_ok" type="radio" value="1" checked>
	   是
	   <input type="radio" name="is_ok" value="0">否</td>
	 </tr>
    <tr><input type="hidden" name="urls" value="<?=$url?>">
	<input type="hidden" name="act_tj" value="ok">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
  <?php
}
?>
  <?php
if($_GET['xg']){
$rs=mysql_query("select * from adwords where id=$_GET['xg_id']");
$row=mysql_fetch_array($rs)
?>
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="" onSubmit="return check()" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加热点产品目录</td>
    </tr>
    <tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">会员编号[ID]</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="member_id" type="text" id="member_id" size="30" maxlength="100" value="<?=$row[member_id]?>"></td>
    </tr>
    <tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">广告类型</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="type_id" id="type_id">
	     <option value="">选择广告类型</option>
	     <option value="1" <?php if($row[type_id]==1){echo "selected";}?>>热点产品广告</option>
		 <option value="2" <?php if($row[type_id]==2){echo "selected";}?>>产品栏目列表广告（横幅）</option>
		 <option value="3" <?php if($row[type_id]==3){echo "selected";}?>>产品栏目列表广告（竖幅）</option>
	  </select></td>
    </tr>
	<tr>
      <td width="17%" height="30" align="center" bgcolor="#FFFFFF">页面编号[ID]</td>
      <td width="83%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_id" type="text" id="ad_id" size="20" value="<?=$row[ad_id]?>"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">链接地址</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_url" type="text" id="ad_url" size="40" value="<?=$row[ad_url]?>"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">图片地址</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="picture" type="text" id="picture" size="30" value="<?=$row[ad_picture]?>">&nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">开始时间</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_addtime" type="text" id="ad_addtime" size="20" onClick="setDay(this);" value="<?=$row[ad_addtime]?>"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">结束时间</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="ad_endtime" type="text" id="ad_endtime" size="20" onClick="setDay(this);"  value="<?=$row[ad_endtime]?>"></td>
	 </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">备注</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><textarea name="ad_shuoming" cols="60" rows="10" id="ad_shuoming"><?=$row[ad_shuoming]?></textarea></td>
	 </tr>
	 <tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">是否显示</td>
	   <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	   <input type="radio" name="is_ok" value="1" <?php if($row[is_ok]==1){echo "checked";}?>>是
	   <input type="radio" name="is_ok" value="0" <?php if($row[is_ok]==0){echo "checked";}?>>否</td>
	 </tr>
      <tr><input type="hidden" name="urls" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php }?>
<div style="color:red;">注：备注内容：关键字，页面地址，账号，会员编号等信息</div>
</center>
</BODY>
</HTML>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function check(){
if($("type_id").value==""){
alert("广告类型不能为空");
$("type_id").focus();
return false
}
if($("ad_id").value==""){
alert("页面编号不能为空");
$("ad_id").focus();
return false;
}
if(isNaN($("ad_id").value)){
alert("页面编号为数字");
$("ad_id").focus();
return false; 
}
if($("picture").value==""){
alert("请上传图片");
$("picture").focus();
return false;
}
if($("ad_addtime").value==""){
alert("广告开始时间不能为空");
$("ad_addtime").focus();
return false;
}
if($("ad_endtime").value==""){
alert("广告结束时间不能为空");
$("ad_endtime").focus();
return false;
}
}
</script>